convert vcl/menu.hxx from XubString to OUString (second attempt)
Change-Id: I579525326be702ffbb57d49970da5804fd2fe12d
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 5cc1af4..54bb0a6 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -420,7 +420,7 @@
// add an arbitrary button to the menubar (will appear next to closer)
// passed link will be call with a MenuBarButtonCallbackArg on press
// passed string will be set as tooltip
sal_uInt16 AddMenuBarButton( const Image&, const Link&, const String&, sal_uInt16 nPos = 0 );
sal_uInt16 AddMenuBarButton( const Image&, const Link&, const OUString&, sal_uInt16 nPos = 0 );
// set the highlight link for additional button with ID nId
// highlight link will be called with a MenuBarButtonHighlightArg
// the bHighlight member of that struct shall contain the new state
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 2e5ad68..696a928 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -629,9 +629,9 @@
long GetCtrlTextWidth( const OUString& rStr, xub_StrLen nIndex = 0,
xub_StrLen nLen = STRING_LEN,
sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC ) const;
static OUString GetNonMnemonicString( const OUString& rStr, xub_StrLen& rMnemonicPos );
static OUString GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos );
static OUString GetNonMnemonicString( const OUString& rStr )
{ xub_StrLen nDummy; return GetNonMnemonicString( rStr, nDummy ); }
{ sal_Int32 nDummy; return GetNonMnemonicString( rStr, nDummy ); }
sal_Bool GetTextBoundRect( Rectangle& rRect,
const OUString& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 4a257d4..0f61edfd 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -6145,7 +6145,7 @@
long nTextHeight = rTargetDevice.GetTextHeight();
TextAlign eAlign = rTargetDevice.GetTextAlign();
xub_StrLen nMnemonicPos = STRING_NOTFOUND;
sal_Int32 nMnemonicPos = STRING_NOTFOUND;
OUString aStr = rOrigStr;
if ( nStyle & TEXT_DRAW_MNEMONIC )
@@ -6721,7 +6721,7 @@
nLen = rStr.getLength() - nIndex;
OUString aStr = rStr;
xub_StrLen nMnemonicPos = STRING_NOTFOUND;
sal_Int32 nMnemonicPos = STRING_NOTFOUND;
long nMnemonicX = 0;
long nMnemonicY = 0;
@@ -6835,14 +6835,14 @@
if ( nStyle & TEXT_DRAW_MNEMONIC )
{
xub_StrLen nMnemonicPos;
sal_Int32 nMnemonicPos;
OUString aStr = GetNonMnemonicString( rStr, nMnemonicPos );
if ( nMnemonicPos != STRING_NOTFOUND )
{
if ( nMnemonicPos < nIndex )
nIndex--;
else if ( (nLen < STRING_LEN) &&
(nMnemonicPos >= nIndex) && (nMnemonicPos < (sal_uLong)(nIndex+nLen)) )
(nMnemonicPos >= nIndex) && ((sal_uLong)nMnemonicPos < (sal_uLong)(nIndex+nLen)) )
nLen--;
}
return GetTextWidth( aStr, nIndex, nLen );
@@ -6851,27 +6851,27 @@
return GetTextWidth( rStr, nIndex, nLen );
}
OUString OutputDevice::GetNonMnemonicString( const OUString& rStr, xub_StrLen& rMnemonicPos )
OUString OutputDevice::GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos )
{
String aStr = rStr;
xub_StrLen nLen = aStr.Len();
xub_StrLen i = 0;
OUString aStr = rStr;
sal_Int32 nLen = aStr.getLength();
sal_Int32 i = 0;
rMnemonicPos = STRING_NOTFOUND;
while ( i < nLen )
{
if ( aStr.GetChar( i ) == '~' )
if ( aStr[ i ] == '~' )
{
if ( aStr.GetChar( i+1 ) != '~' )
if ( aStr[ i+1 ] != '~' )
{
if ( rMnemonicPos == STRING_NOTFOUND )
rMnemonicPos = i;
aStr.Erase( i, 1 );
aStr = aStr.replaceAt( i, 1, "" );
nLen--;
}
else
{
aStr.Erase( i, 1 );
aStr = aStr.replaceAt( i, 1, "" );
nLen--;
i++;
}
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 2757f76..baa82e5 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -7909,7 +7909,7 @@
Point aPos = rRect.TopLeft();
long nTextHeight = m_pReferenceDevice->GetTextHeight();
xub_StrLen nMnemonicPos = STRING_NOTFOUND;
sal_Int32 nMnemonicPos = STRING_NOTFOUND;
OUString aStr = rOrigStr;
if ( nStyle & TEXT_DRAW_MNEMONIC )
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index e544cc0..3de8686 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -741,7 +741,7 @@
Size MinCloseButtonSize();
// add an arbitrary button to the menubar (will appear next to closer)
sal_uInt16 AddMenuBarButton( const Image&, const Link&, const String&, sal_uInt16 nPos );
sal_uInt16 AddMenuBarButton( const Image&, const Link&, const OUString&, sal_uInt16 nPos );
void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link& );
Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId );
void RemoveMenuBarButton( sal_uInt16 nId );
@@ -841,12 +841,12 @@
{
// is an id available, then call help with the id, otherwise
// use help-index
String aCommand = pMenu->GetItemCommand( nId );
OUString aCommand = pMenu->GetItemCommand( nId );
OString aHelpId( pMenu->GetHelpId( nId ) );
if( aHelpId.isEmpty() )
aHelpId = OOO_HELP_INDEX;
if ( aCommand.Len() )
if ( !aCommand.isEmpty() )
pHelp->Start( aCommand, NULL );
else
pHelp->Start( OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), NULL );
@@ -1270,7 +1270,7 @@
if ( nObjMask & RSC_MENUITEM_STATUS )
nStatus = sal::static_int_cast<MenuItemBits>(ReadLongRes());
String aText;
OUString aText;
if ( nObjMask & RSC_MENUITEM_TEXT )
aText = ReadStringRes();
@@ -1280,7 +1280,7 @@
if ( !bSep )
{
Bitmap aBmp( ResId( (RSHEADER_TYPE*)GetClassRes(), *pMgr ) );
if ( aText.Len() )
if ( !aText.isEmpty() )
InsertItem( nItemId, aText, aBmp, nStatus, OString(), nPos );
else
InsertItem( nItemId, aBmp, nStatus, OString(), nPos );
@@ -1328,7 +1328,7 @@
}
if ( nObjMask & RSC_MENUITEM_COMMAND )
{
String aCommandStr = ReadStringRes();
OUString aCommandStr = ReadStringRes();
if ( !bSep )
SetItemCommand( nItemId, aCommandStr );
}
@@ -2027,7 +2027,10 @@
{
MenuItemData* pData = pItemList->GetData( nItemId );
if ( pData )
assert ( pData );
if ( pData->aHelpText.isEmpty() &&
(( !pData->aHelpId.isEmpty() ) || ( !pData->aCommandStr.isEmpty() )))
{
if ( pData->aHelpText.isEmpty() &&
(( !pData->aHelpId.isEmpty() ) || ( !pData->aCommandStr.isEmpty() )))
@@ -2042,8 +2045,6 @@
pData->aHelpText = pHelp->GetHelpText( OStringToOUString( pData->aHelpId, RTL_TEXTENCODING_UTF8 ), NULL );
}
}
return pData->aHelpText;
}
return OUString();
@@ -2064,6 +2065,8 @@
OUString Menu::GetTipHelpText( sal_uInt16 nItemId ) const
{
static const OUString EMPTY("");
MenuItemData* pData = pItemList->GetData( nItemId );
if ( pData )
@@ -2476,7 +2479,7 @@
// Accel
if ( !bIsMenuBar && pData->aAccelKey.GetCode() && !ImplAccelDisabled() )
{
String aName = pData->aAccelKey.GetName();
OUString aName = pData->aAccelKey.GetName();
long nAccWidth = pWin->GetTextWidth( aName );
nAccWidth += nExtra;
nWidth += nAccWidth;
@@ -2597,20 +2600,20 @@
}
}
static String getShortenedString( const String& i_rLong, Window* i_pWin, long i_nMaxWidth )
static OUString getShortenedString( const OUString& i_rLong, Window* i_pWin, long i_nMaxWidth )
{
xub_StrLen nPos = STRING_NOTFOUND;
String aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) );
sal_Int32 nPos = STRING_NOTFOUND;
OUString aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) );
aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS );
// re-insert mnemonic
if( nPos != STRING_NOTFOUND )
{
if( nPos < aNonMnem.Len() && i_rLong.GetChar(nPos+1) == aNonMnem.GetChar(nPos) )
if( nPos < aNonMnem.getLength() && i_rLong[nPos+1] == aNonMnem[nPos] )
{
OUStringBuffer aBuf( i_rLong.Len() );
aBuf.append( aNonMnem.GetBuffer(), nPos );
OUStringBuffer aBuf( i_rLong.getLength() );
aBuf.append( aNonMnem.copy( 0, nPos) );
aBuf.append( sal_Unicode('~') );
aBuf.append( aNonMnem.GetBuffer()+nPos );
aBuf.append( aNonMnem.copy(nPos) );
aNonMnem = aBuf.makeStringAndClear();
}
}
@@ -2848,8 +2851,8 @@
{
nMaxItemTextWidth -= nFontHeight - nExtra;
}
String aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) );
pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.Len(), nStyle, pVector, pDisplayText );
OUString aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) );
pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText );
if( bSetTmpBackground )
pWin->SetBackground();
}
@@ -3468,7 +3471,7 @@
return sal_False;
}
sal_uInt16 MenuBar::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const String& i_rToolTip, sal_uInt16 i_nPos )
sal_uInt16 MenuBar::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const OUString& i_rToolTip, sal_uInt16 i_nPos )
{
return pWindow ? static_cast<MenuBarWindow*>(pWindow)->AddMenuBarButton( i_rImage, i_rLink, i_rToolTip, i_nPos ) : 0;
}
@@ -6045,7 +6048,7 @@
return xAcc;
}
sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const String& i_rToolTip, sal_uInt16 i_nPos )
sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const OUString& i_rToolTip, sal_uInt16 i_nPos )
{
// find first free button id
sal_uInt16 nId = IID_DOCUMENTCLOSE;